import pysam
import argparse
def parse_args():
    parser = argparse.ArgumentParser("")
    parser.add_argument("--bam", type=str,required=False,default='/home/xiaoyifu/data/HG002/R9.4/dorado/mod_infer.sorted.dorado.5mc.full.bam')
    parser.add_argument("--output",'-o', type=str,required=False,default='/home/xiaoyifu/data/HG002/R9.4/dorado/reverse_strand.txt')
    return parser.parse_args()
args=parse_args()
bamfile = pysam.AlignmentFile(args.bam, "rb", check_sq=False)
wf=open(args.output, 'w')
for read in bamfile.fetch(until_eof=True):
    if read.is_reverse:
        wf.write(read.query_name+'\n')

    
